<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="/Public/js/three.min.js"></script>
    <script src="/Public/js/OrbitControls.js"></script>
    <script src="/Public/js/jquery-3.7.1.min.js"></script>
    <script src="/Public/js/geotiff.js"></script>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background: #1a1a2e;
            font-family: Arial, sans-serif;
        }
    </style>

</head>

<body>
    <script>
        const scene = new THREE.Scene();
        scene.background = new THREE.Color(0x1a1a2e);

        // 创建相机
        const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 10000);
        camera.position.set(1, 50, 3);

        // 创建渲染器
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        // 添加光源
        const ambientLight = new THREE.AmbientLight(0x404040);
        scene.add(ambientLight);
        const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
        directionalLight.position.set(1, 1, 1);
        scene.add(directionalLight);

        // 添加控制器
        const controls = new THREE.OrbitControls(camera, renderer.domElement);
        controls.enableDamping = true;

        const geometry = new THREE.CircleGeometry(4, 32);

        geometry.rotateX(Math.PI / 2);

        const vs1 = `
            varying vec2 vUv;
            void main() {
                vUv = uv;
                gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
            }
        `;

        const fs1 = `
            varying vec2 vUv;
            void main() {
                vec2 center = vec2(0.5, 0.5);
                float dist = distance(vUv, center);
                float res = step(dist,0.1);

                vec3 color = mix(vec3(0.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0), res);
                gl_FragColor = vec4(color, 1.0);
            }
        `;


        const fs2 = `
            varying vec2 vUv;
            void main() {
                vec2 center = vec2(0.5, 0.5);
                float dist = distance(vUv, center);
                
                float ring = step(0.3, dist)*step(dist,0.4) ;
                gl_FragColor = vec4(1.0, 1.0, 0.0, ring);
            }
        `;

        const fs3 = `
            varying vec2 vUv;
            uniform float time;
            void main() {
                vec2 center = vec2(0.5, 0.5);
                float dist = distance(vUv, center);
                
                //ring为0或1
                float ring = step(fract(time)*0.4 + 0.1, dist)*step(dist,fract(time + 0.1)*0.4 + 0.1 ) ;
                gl_FragColor = vec4(1.0, 1.0, 0.0, ring);
            }
        `;

        const fs4 = `
            varying vec2 vUv;
            uniform float time;
            void main() {
                vec2 center = vec2(0.5, 0.5);
                float dist = distance(vUv, center);
                
                float innerRadius = fract(time) * 0.2 + 0.1;
                float outerRadius = innerRadius + 0.05; 
                
                // ring为float,透明度渐变
                float ring = smoothstep(innerRadius - 0.02, innerRadius, dist) * 
                            smoothstep(outerRadius + 0.02, outerRadius, dist);
                gl_FragColor = vec4(1.0, 1.0, 0.0, ring);
            }
        `;

        const shaderMaterial = new THREE.ShaderMaterial({
            vertexShader: vs1,
            fragmentShader: fs4,
            side: THREE.DoubleSide,
            uniforms: {
                time: { value: 0.0 }
            },
            transparent: true,
        });

        const mesh = new THREE.Mesh(geometry, shaderMaterial);
        scene.add(mesh)
        // 动画循环
        function animate() {
            requestAnimationFrame(animate);
            shaderMaterial.uniforms.time.value += 0.005;
            controls.update();
            renderer.render(scene, camera);
        }
        animate();


    </script>
</body>

</html>